<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/common/common-css.jsp" %>
<style>
		#jquery-table td{cursor:pointer !important}
		.load_bg{background:#000;opacity:0.1;left:0px;top:0px;position:fixed;height:100%;width:100%;overflow:hidden;z-index:10000;}
		.load_img{left:50%;top:180px;position:fixed;height:50px;overflow:hidden;z-index:20000;}
		</style>
	</head>
<body  class="no-skin">

<div  class="load_bg" style="display:none"></div>
<img src="http://img.xmiles.cn/commentloading.gif" class="load_img" style="display:none"/>
	<div class="page-content"> 
		<form id="queryForm" action="" method="POST"> 
			<div class="page-content-area"> 
				<div class="row">
  					<div class="col-sm-12">
						<div class="widget-box" style="border:0px solid #ccc; border-top:none;border-bottom:none;margin-top:15px;">
							<hr style="margin-top:0px;margin-bottom:0x">
							<div class="widget-header widget-header-blue widget-header-flat">
									<h4 class="widget-title">选择条件进行查询</h4>
									<div class="widget-toolbar">
										<a href="#" data-action="collapse">
											<i class="ace-icon fa fa-chevron-up"></i>
										</a>
									</div>
							</div>
							<div class=" widget-body">
								<div class="widget-main" >
																					
										   <div class="form-group col-xs-12 col-sm-4 "> 
												<label class="col-sm-2 control-label"  style="text-align:right"  for="sex">时间:</label>
												<div class="col-sm-6">
													<div class="input-daterange input-group col-sm-12">
														<input type="text" data-date-format="yyyy-mm-dd hh:ii" class="fromDate date-picker input-sm form-control" style="padding-left:0px" name="startTime">
														<span class="input-group-addon" style="width:6px">
															<i class="fa fa-exchange"></i>
														</span>
														<input type="text" data-date-format="yyyy-mm-dd hh:ii" class="endDate date-picker input-sm form-control" style="padding-left:0px" name="endTime">
													</div>
												</div>
											</div>
		
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >平台:</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-6">
														<select name="platform">
															<option value="">---请选择---</option>
															<option value="all">全部</option>
															<option value="android">android</option>
															<option value="ios">ios</option>
														</select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">产品：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="prdList" name="prd_id" list="%{paramsMap.prdList}" listKey="prdid" listValue="name" 
															headerKey="" headerValue="------请选择------" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >渠道：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="channelList" name="channel" list="%{paramsMap.channelList}" listKey="channel_code" listValue="channel_name" 
															headerKey="" headerValue="------请选择------" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>	
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >追溯期:</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-6">
														<select name="mode">
															<option value="1">激活当天</option>
															<option value="3">激活后3天内</option>
															<option value="7">激活后7天内</option>
															<option value="15">激活后15天内</option>
															<option value="30">激活后30天内</option>
															<option value="60">激活后60天内</option>
														</select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >数据显示:</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-6">
														<select name="type">
															<option value="">按数值</option>
															<option value="1">按比例</option>
														</select>
													</div>
												</div>
											</div>
		
									</div><!-- /.widget-main -->
								</div><!-- /.widget-body -->
						</div><!-- /.widget-box -->
					</div><!-- /.col-sm-12 -->
					
					<div class="col-md-12 center">
						<div class="clearfix form-actions">
				
							<button class="btn btn-purple  no-border" type="button" name="btn-query" onclick="query_any()" id="btn-query" > 
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i> 
								查询 
							</button> 
							&nbsp;&nbsp;&nbsp;
							<button class="btn btn-grey  no-border" type="reset">
								<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
								重置
							</button>
							
				 		 </div>
		  			 </div>
				
				</div><!-- /.row -->
				
				<div class="row">
					<div class="col-xs-12">
						<a id="loadButton" href="javascript:void(0)"
							class="btn btn-success btn-small" style="display: none"
							id="output2" onclick="loadlist()">导出CSV</a>&nbsp;&nbsp;&nbsp;
					</div>
					<!-- /.col -->
				</div>
					 
				<hr style="display:none;" id="delete_hr">
					<div class="row">
					<div class="col-xs-12">
						<table id="jquery-table" class="table table-striped table-bordered table-hover">
						</table>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div><!-- /.page-content-area -->
		</form>
	</div><!-- /.page-content -->
				
<%@ include file="/common/common-js.jsp" %>

<!-- inline scripts related to this page -->

<script type="text/javascript">

	function loadlist(){
		var form = document.forms["queryForm"];
		form.action= ctx + "/stat/downloadUserCore.action"; 
		form.submit();
	}

	//【查询】按钮Click事件
	function query_any() {
		$("#loadButton").show();
		$(".load_bg").removeAttr("style");
		$(".load_img").removeAttr("style");
		if (jqTable != null) {
			jqTable.fnDraw();
		} else {
			loaddata();
		}
		$("#delete_hr").attr("style", "margin-top:0px;margin-bottom:20px;display:block");
	}
	var jqTable = null;
	var loaddata = function() {
		jQuery(function($) {
			jqTable = $('#jquery-table').dataTable(
					{
						"columnDefs" : [ {
							"title" : '日期',
							"targets" : [ 0 ],
							"data" : "date",//返回的数据 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						}, {
							"title" : '平台',
							"targets" : [ 1 ],
							"data" : "platform",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						}, {
							"title" : '产品',
							"targets" : [ 2 ],
							"data" : "prd_name",
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						}, {
							"title" : '渠道',
							"targets" : [ 3 ],
							"data" : "channel_name", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						}, {
							"title" : '激活周期',
							"targets" : [ 4 ],
							"data" : "mode", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%",
							"render" : function(value, type, row) {
								switch (value) {
								case '1':
									value = '激活当天';
									break;
								case '3':
									value = '激活3天内';
									break;
								case '7':
									value = '激活7天内';
									break;
								case '15':
									value = '激活15天内';
									break;
								case '30':
									value = '激活30天内';
									break;
								case '60':
									value = '激活60天内';
									break;
								default:
									value = value;
									break;
								}
								return value;
							}
						},
						{
							"title" : '新增人数',
							"targets" : [ 5 ],
							"data" : "increase", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '新增登录人数',
							"targets" : [ 6 ],
							"data" : "new_login", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '注册成功人数',
							"targets" : [ 7 ],
							"data" : "register", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '签到成功人数',
							"targets" : [ 8 ],
							"data" : "sign", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '大转盘抽奖人数',
							"targets" : [ 9 ],
							"data" : "lucky_turn", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '每周大奖人数',
							"targets" : [ 10 ],
							"data" : "lucky_week", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '创建资料人数',
							"targets" : [ 11 ],
							"data" : "setup", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : 'API进件数',
							"targets" : [ 12 ],
							"data" : "api_in", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						},
						{
							"title" : '贷款申请成功数',
							"targets" : [ 13 ],
							"data" : "loan", 
							"class" : "center",
							"bSortable" : false,
							"width" : "5%"
						}
						],
						"sAjaxSource" : ctx + "/stat/statusercorelist.action", // 数据源URL
						"fnServerData" : function(sSource, aoData,
								fnCallback) {//从服务器请求数据
							var data = $('#queryForm').serializeObject();
							data.aoData = JSON.stringify(aoData);
							$.ajax({
								"dataType" : 'json',
								"type" : "POST",
								"url" : sSource,
								"data" : data,
								"success" : function(resp) {
									fnCallback(resp);
									initListPage();
									$(".load_bg").attr("style",
											"display:none");
									$(".load_img").attr("style",
											"display:none");
								},
								"error" : function(XMLHttpRequest,
										textStatus, errorThrown) {
									$(".load_bg").attr("style",
											"display:none");
									$(".load_img").attr("style",
											"display:none");
									alert('请求服务器错误,请刷新重试！！');//错误提示，包括服务器重启导致的session失效
								},
							});
						},
						"sScrollXInner" : "100%",
						"sScrollY" : "100%",//如果不设置，IE会有问题
						"aaSorting" : [ [ 1, "desc" ] ]
					});
		});
	}
	jQuery(function() {
		$(".date-picker").datepicker({
			autoclose : true,
			format : 'yyyy-mm-dd'
		});
		$("#prdList").combobox();
		$("#channelList").combobox();
	});
</script>
</body>
</html>
